package com.quktzhuanka.app.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.quktzhuanka.app.R;
import com.quktzhuanka.app.activity.NewsActivity;
import com.quktzhuanka.app.bean.MessageCenterBean;
import com.quktzhuanka.app.config.Constants;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.List;

public class XtAdapter extends CommonAdapter<MessageCenterBean.MessageCenterChildBean> {

    public XtAdapter(Context context, int layoutId, List<MessageCenterBean.MessageCenterChildBean> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder holder, final MessageCenterBean.MessageCenterChildBean shopBean, final int position) {
        Glide.with(mContext).load(Constants.APP_IP+shopBean.getImg()).error(R.drawable.xt).into((ImageView) holder.getView(R.id.round_img));
        holder.setText(R.id.txt_name,shopBean.getTitle());
        holder.setText(R.id.txt_address,shopBean.getPubtime().substring(0,shopBean.getPubtime().length()-3));
        holder.setText(R.id.txt_share_num,shopBean.getClicknum()+"人阅读");
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, NewsActivity.class);
                intent.putExtra("title", shopBean.getTitle());
                intent.putExtra("article_id",shopBean.getArticle_id());
                intent.putExtra("type","1");
                mContext.startActivity(intent);
            }
        });
    }
}
